﻿@model VinhSon.Intranet.Models.PermissionModel
@{
    ViewBag.Title = "Edit Permission";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section script
{
    <script type="text/javascript">
        function submitForm() {
            if (window.App.FormPanel1.getForm().isValid())
                request('@Url.Action("Edit")', window.App.FormPanel1.getValue(), function(result) {
                    showNotification(window.parent, result, function() {
                        window.parent.App.gvData.getStore().reload();
                        window.parent.App.winEdit.close();
                    });
                }, function() {
                    window.Ext.Msg.show(
                        {
                            title: "Confirm",
                            buttons: window.Ext.Msg.YES,
                            fn: function() {
                                window.parent.App.winEdit.close();
                            },
                            icon: window.Ext.Msg.ERROR,
                            msg: "There some errors occour when update. Please try again later."
                        });
                });
        }
    </script>
}
@(Html.X()
      .FormPanel()
      .ID("FormPanel1")
      .Method(HttpMethod.POST)
      .BodyPadding(10)
      .Border(false)
      .Title("Edit Permission: " + Model.Name)
      .Items(form =>
                 {
                     form.Add(Html.X()
                                  .HiddenFor(c => c.Id));
                     form.Add(Html.X()
                                  .TextFieldFor(c => c.Name)
                                  .FieldLabel("Name")
                                  .AllowBlank(false)
                                  .MaxLength(100)
                                  .EmptyText("Name"));
                     form.Add(Html.X()
                                  .TextFieldFor(c => c.KeyName)
                                  .FieldLabel("Key Name")
                                  .MaxLength(100)
                                  .EmptyText("Key Name"));
                     form.Add(Html.X()
                                  .TextFieldFor(c => c.GroupName)
                                  .FieldLabel("Group Name")
                                  .MaxLength(100)
                                  .EmptyText("Group Name"));
                     form.Add(Html.X()
                                  .TextAreaFor(c => c.Description)
                                  .FieldLabel("Description")
                                  .MaxLength(200)
                                  .Width(420)
                                  .EmptyText("Description"));
                     form.Add(Html.X()
                                  .Button()
                                  .FormBind(true)
                                  .Text("Update")
                                  .MarginSpec("0 5 0 100")
                                  .OnClientClick("submitForm"));
                     form.Add(Html.X()
                                  .Button()
                                  .Text("Cancel")
                                  .OnClientClick("window.parent.App.winEdit.close();"));
                 }))